package com.serviceImpl;

import com.github.pagehelper.PageHelper;
import com.javabean.Product;
import com.mapper.ProductMapper;
import com.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * @Author: 张波
 * @Time: 2025/8/27 10:46
 */
@Service
public class ProductServiceImpl implements ProductService {
	ProductMapper productMapper;
	@Autowired
	public ProductServiceImpl(ProductMapper productMapper) {
		this.productMapper = productMapper;
	}
	/**
	 *
	 * @return List<Product>
	 */
	@Override
	public List<Product> findAll() {
		return productMapper.selectAll();
	}

	/**
	 *
	 * @param name 名字
	 * @return List<Product>
	 */
	@Override
	public List<Product>  findProductName(String name) {
		return productMapper.selectLikeProductName(name);
	}

	/**
	 *
	 * @param id 根据id进行查询
	 * @return 返回product对象
	 */
	@Override
	public Product findById(int id) {
		return productMapper.selectById(id);
	}

	/**
	 *
	 * @param product 传入product对象
	 * @return 返回受影响行数
	 */
	@Override
	public int updateProduct(Product product) {
		return productMapper.updateProduct(product);
	}

	/**
	 *
	 * @param product 传入product对象
	 * @return 返回受影响行数
	 */
	@Override
	public int addProduct(Product product) {
		return productMapper.insertProduct(product);
	}

	/**
	 *
	 * @param id 传入需要删除的id
	 * @return 删除结果为受影响行数
	 */
	@Override
	public int deleteById(int id) {
		return productMapper.deleteById(id);
	}

	/**
	 *
	 * @param ids
	 * @return
	 */
	@Override
	public int deleteMore(List<Integer> ids) {
		return productMapper.deleteAll(ids);
	}

}
